# hello_langchain.py
import os
from langchain_openai import ChatOpenAI


def hello_langchain():
    """第一个LangChain程序"""

    print("👋 Hello LangChain!")

    # 1. 创建LLM实例
    llm = ChatOpenAI(
        api_key=os.getenv("DASHSCOPE_API_KEY"),
        base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
        model="qwen-turbo"
    )

    # 2. 发送消息
    response = llm.invoke("请介绍一下你自己")

    # 3. 输出结果
    print("🤖 AI回复：")
    print(response.content)


# 运行程序
hello_langchain()
